package cn.iocoder.yudao.module.book.dal.mysql.plans;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.book.dal.dataobject.plans.PlansDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.plans.vo.*;

/**
 * 阅读计划 Mapper
 *
 * @author xi
 */
@Mapper
public interface PlansMapper extends BaseMapperX<PlansDO> {

    default PageResult<PlansDO> selectPage(PlansPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlansDO>()
                .eqIfPresent(PlansDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(PlansDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PlansDO::getBookId, reqVO.getBookId())
                .eqIfPresent(PlansDO::getCollectionId, reqVO.getCollectionId())
                .likeIfPresent(PlansDO::getPlanName, reqVO.getPlanName())
                .eqIfPresent(PlansDO::getPlanType, reqVO.getPlanType())
                .eqIfPresent(PlansDO::getDailyCount, reqVO.getDailyCount())
                .eqIfPresent(PlansDO::getReviewSchedule, reqVO.getReviewSchedule())
                .betweenIfPresent(PlansDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PlansDO::getPlanId));
    }

}